//
// Created by hujin on 2023/3/9.
//

#ifndef SI_GLOBAL_STATS_H
#define SI_GLOBAL_STATS_H


#include <functional>

template<typename T, typename I>
class GlobalStats {

    bool directed = true;
public:
    virtual T query(I id_s, I id_t) = 0;

    T biquery(I id1, I id2);

    virtual void recycle(I node) = 0;

    virtual void combine(I id1, I id2, I id_new) = 0;


    virtual void copy(I id1, I id_new) = 0;

    virtual void remove(I id_parent, I id_child) = 0;

    virtual void modify(I id_s, I id_t, T p) = 0;

    virtual void iterate_neighbor(I id, std::function<void(I, T)>) = 0;

    virtual void query_sum_in(I id_t) = 0;
};

template<typename T, typename I> T GlobalStats<T, I>::biquery(I id1, I id2) {
    return directed ? query(id1, id2) + query(id2, id1) : 2 * query(id1, id2);

}

#endif //SI_GLOBAL_STATS_H
